﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Web.Cms.Content.Zones
{
    public partial class AjaxServer : System.Web.UI.Page
    {
        string SelectedNode;
        protected void Page_Load(object sender, EventArgs e)
        {

            SelectedNode = Request.Params["SelectedNode"];
            if (Request.Params["SelectedNode"] != null)
            {
                if (SelectedNode.Length > 0)
                {
                    Response.Clear();

                    string Xml = GetData();

                    Response.Clear();

                    Response.ContentType = "text/xml";

                    Response.Write(Xml);

                    Response.End();
                }
                else
                {
                    Response.End();
                    Response.Clear();
                }
            }
            else
            {
                Response.End();
                Response.Clear();
            }

        }

        public string GetData()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(@"<?xml version=""1.0"" encoding=""utf-8"" ?>");
            if (SelectedNode == "1")// Module chủ
            {
                sb.Append(@"<zones>");
                sb.Append(@"<zone id='/default.aspx'><![CDATA[Trang chủ]]></zone>");
                sb.Append(@"</zones>");
            }
            else if (SelectedNode == "2")// Module tin tức
            {
                sb.Append(@"<zones>");
                sb.Append(@"<zone id='21'><![CDATA[Trang tin tức]]></zone>");
                sb.Append(@"</zones>");
            }
            else if (SelectedNode == "3")// Module sản phẩm
            {
                sb.Append(@"<zones>");
                sb.Append(@"<zone id='31'><![CDATA[Hiển thị dạng danh sách]]></zone>");
                sb.Append(@"</zones>");
            }
            else if (SelectedNode == "4")// Module sản phẩm
            {
                sb.Append(@"<zones>");
                sb.Append(@"<zone id='41'><![CDATA[--------------------]]></zone>");
                sb.Append(@"</zones>");
            }
            else if (SelectedNode == "5")// Module sản phẩm
            {
                sb.Append(@"<zones>");
                sb.Append(@"<zone id='51'><![CDATA[---------------------]]></zone>");
                sb.Append(@"</zones>");
            }  
            else
            {
                sb.Append(@"<zones>");
                sb.Append(@"<zone id='/default.aspx'><![CDATA[Trang chủ]]></zone>");
                sb.Append(@"</zones>");
            }
            return sb.ToString();
        }
    }
}